package com.zhr.tea.view.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import java.util.List;

/**
 * Created by ym on 2016/11/3.
 */

public class DingdanViewpagerAdapter extends FragmentStatePagerAdapter {
    private String[] title;
    private List<Fragment>data;

    public DingdanViewpagerAdapter(FragmentManager fm) {
        super(fm);
    }

    public DingdanViewpagerAdapter(FragmentManager fm, List<Fragment> data, String[] title) {
        super(fm);
        this.data = data;
        this.title = title;
    }

    @Override
    public Fragment getItem(int position) {
        return data.get(position);
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return title.length != 0 ? title[position] : null;
    }
}
